﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using BrowserGameFramework.Messaging.Interfaces;

namespace BrowserGameFramework.Messaging
{
    [Serializable]
    [XmlRoot("Messages")]
    public class MessageHeaderCollection : ICollection<MessageHeader>
    {
        private List<MessageHeader> messages = new List<MessageHeader>();

        #region ICollection<Message> Member

        public void Add(MessageHeader item)
        {
            messages.Add(item);
        }

        public void Clear()
        {
            messages.Clear();
        }

        public bool Contains(MessageHeader item)
        {
            return messages.Contains(item);
        }

        public void CopyTo(MessageHeader[] array, int arrayIndex)
        {
            messages.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return messages.Count; }
        }

        public bool IsReadOnly
        {
            get { throw new NotImplementedException(); }
        }

        public bool Remove(MessageHeader item)
        {
            return messages.Remove(item);
        }

        #endregion

        #region IEnumerable<BaseMessageHeader> Member

        public IEnumerator<MessageHeader> GetEnumerator()
        {
            foreach (MessageHeader msg in messages)
            {
                yield return msg;
            }
        }

        #endregion

        #region IEnumerable Member6

        IEnumerator IEnumerable.GetEnumerator()
        {
            return messages.GetEnumerator();
        }

        #endregion


    }
}
